using Gateway.IApplication.BaseInput;
using Gateway.IApplication.Project;
using Gateway.IApplication.Project.Input;
using Gateway.IQuery;
using Gateway.IQuery.Project;
using Gateway.IQuery.Project.Request;
using Gateway.IQuery.Project.Result;

namespace Gateway.UI.Api.Controllers;

/// <summary>
/// 项目（分组）服务
/// </summary>
public class ProjectController : BaseController
{
    private readonly IProjectApp _projectApp;
    private readonly IProjectQuery _projectQuery;

    /// <summary>
    /// 
    /// </summary>
    /// <param name="projectApp"></param>
    /// <param name="projectQuery"></param>
    public ProjectController(IProjectApp projectApp, IProjectQuery projectQuery)
    {
        _projectApp = projectApp;
        _projectQuery = projectQuery;
    }

    /// <summary>
    /// 创建
    /// </summary>
    /// <param name="input"></param>
    /// <returns>返回主键标识</returns>
    [HttpPost, Route("add")]
    public async Task<bool> Add(CreateProjectInput input)
    {
        return await _projectApp.Add(input);
    }

    /// <summary>
    /// 更新
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpPost, Route("update")]
    public async Task<bool> Update(UpdateProjectInput input)
    {
        return await _projectApp.Update(input);
    }

    /// <summary>
    /// 删除
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpPost, Route("remove")]
    public async Task<bool> Remove(RemoveInput input)
    {
        return await _projectApp.Remove(input.Id);
    }

    /// <summary>
    /// 禁用/启用
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpPost, Route("disable")]
    public async Task<bool> Disable(DisableInput input)
    {
        return await _projectApp.Disable(input.Id, input.Disable);
    }

    /// <summary>
    /// 项目分页列表
    /// </summary>
    /// <returns></returns>
    [HttpPost, Route("list/page")]
    public async Task<PageResult<ProjectPageListResult>> GetPageList(ProjectPageListRequest request)
    {
        return await _projectQuery.GetPageList(request);
    }
}